package com.smartscreen.attendancemanage.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.smartscreen.attendancemanage.entity.LeaveApplication;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface LeaveApplicationMapper extends BaseMapper<LeaveApplication> {
    
    // 移除了与student表和teacher表的JOIN操作，只查询请假申请数据
    @Select("SELECT la.* " +
            "FROM leave_application la " +
            "WHERE la.status = 'pending' " +
            "ORDER BY la.created_at DESC")
    List<LeaveApplication> getPendingApplications();
    
    // 添加根据学生ID查询请假申请的方法
    @Select("SELECT la.* " +
            "FROM leave_application la " +
            "WHERE la.student_id = #{studentId} " +
            "ORDER BY la.created_at DESC")
    List<LeaveApplication> getApplicationsByStudentId(@Param("studentId") String studentId);
    
    // 添加根据状态查询请假申请的方法
    @Select("SELECT la.* " +
            "FROM leave_application la " +
            "WHERE la.status = #{status} " +
            "ORDER BY la.created_at DESC")
    List<LeaveApplication> getApplicationsByStatus(@Param("status") String status);
}